package edu.mama.college.controller;

import edu.mama.college.model.Course;
import edu.mama.college.model.JsonResult;
import edu.mama.college.service.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class CourseController {

    @Autowired
    private CourseService courseService;

    @GetMapping("/course/hot")
    public JsonResult getHotCourses(@RequestParam("limit") int limit){
        List<Course> hotCourses = courseService.getHotCourses(limit);
        return JsonResult.success(hotCourses);
    }

    @GetMapping("course/detail")
    public JsonResult getCourseDetail(@RequestParam("courseId") int courseId){
        Course course = courseService.getCourseDetail(courseId);
        return JsonResult.success(course);
    }

}
